<template>
  <!-- 资金池/自动拆借管理查询结果明细页面弹出框-->
  <el-dialog
    title="资金池/自动拆借管理查询结果明细"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="false"
    @close="closeFn"
  >
    <el-form ref="detailsForm" :model="formData" label-width="180px" :disabled="true">
      <el-row>
        <el-col :span="24">
          <el-form-item label="交易流水号：" prop="id">
            <el-input v-model="formData.id" placeholder="交易流水号" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="报文标识号：" prop="pkgId">
            <el-input v-model="formData.pkgId" placeholder="报文标识号" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="CPG日期：" prop="cpgdate">
            <el-date-picker
              v-model="formData.cpgdate"
              type="date"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="工作日期：" prop="workdate">
            <el-date-picker
              v-model="formData.workdate"
              type="date"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="发起参与机构号：" prop="indirectSender">
            <el-input v-model="formData.indirectSender" placeholder="发起参与机构号" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="发起参与机构名称：" prop="indirectSendername">
            <el-input v-model="formData.indirectSendername" placeholder="发起参与机构名称" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="查询类型：" prop="inqType">
            <el-select v-model="formData.inqType" placeholder="请选择" style="width: 100%">
              <el-option
                v-for="dict in dictMap.QUERY_TYPE_614"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="清算日期：" prop="clrDate">
            <el-date-picker
              v-model="formData.clrDate"
              type="date"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注：" prop="remarks">
            <el-input type="textarea" v-model="formData.remarks" placeholder="备注" maxlength="256" show-word-limit />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="NPC清算日期/终态日期：" prop="npcClrDate">
            <el-date-picker
              v-model="formData.npcClrDate"
              type="datetime"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="NPC处理码：" prop="npcCode">
            <el-input v-model="formData.npcCode" placeholder="NPC处理码" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="NPC轧差场次：" prop="chkRound">
            <el-input v-model="formData.chkRound" placeholder="NPC轧差场次" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="NPC接收时间：" prop="npcRcvTime">
            <el-date-picker
              v-model="formData.npcRcvTime"
              type="datetime"
              value-format="yyyyMMddHHmmss"
              placeholder="选择时间"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="NPC转发时间：" prop="npcTranTime">
            <el-date-picker
              v-model="formData.npcTranTime"
              type="datetime"
              value-format="yyyyMMddHHmmss"
              placeholder="选择时间"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="NPC轧差日期：" prop="chkDate">
            <el-date-picker
              v-model="formData.chkDate"
              type="datetime"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="NPC拒绝信息：" prop="rejectInfo">
            <el-input
              type="textarea"
              v-model="formData.rejectInfo"
              placeholder="NPC拒绝信息"
              maxlength="256"
              show-word-limit
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="明细数目：" prop="txnNum">
            <el-input v-model="formData.txnNum" placeholder="明细数目" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div style="height: 300px; margin-bottom: 20px">
      <ht-table
        ref="flowTable"
        :showSerialNumber="false"
        :multi-select="false"
        :dictMap="dictMap"
        :reqConfig="reqConfig"
        :queryParams="queryParams"
        :tableBindColumns="tableBindColumns"
        :opButtonList="opButtonList"
        :randomRowKey="true"
        :initData="false"
        defaultEventKey="flowTable"
        style="height: 100%"
      >
        <template v-slot:operate>
          <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <ht-button-group
                :buttonList="[
                  {
                    label: '明细',
                    // permission: 'user:xxx:xxx',
                    doFunc: () => {
                      handleAction('detailsInfo', scope.row);
                    },
                  },
                ]"
              />
            </template>
          </el-table-column>
        </template>
      </ht-table>
    </div>
    <el-form ref="detailsForm" :model="formData" label-width="180px" :disabled="true">
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="中心状态：" prop="procStatus">
            <el-select v-model="formData.procStatus" placeholder="请选择" style="width: 100%">
              <el-option
                v-for="dict in dictMap.PROCESSSTATUS"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="通讯状态：" prop="status">
            <el-select v-model="formData.status" placeholder="请选择" style="width: 100%">
              <el-option
                v-for="dict in dictMap.PKG_STATUS"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="报文发送时间：" prop="sndTime">
            <el-date-picker
              v-model="formData.sndTime"
              type="datetime"
              value-format="yyyyMMddHHmmss"
              placeholder="选择时间"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="通用处理码：" prop="commCode">
            <el-input v-model="formData.commCode" placeholder="通用处理码" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="closeFn">关闭</el-button>
    </div>
    <!-- 明细操作弹出框 -->
    <ost-info ref="ostInfoDialog" :dictMap="dictMap" :detailsData="detailsData" :formData="formData"></ost-info>
  </el-dialog>
</template>
<script>
import { detailTabSearch } from "@/api/cnaps/saps/poolingAndAutoMng/funds_borrow_result.js";
import OstInfo from "./ostInfo";
import { amountThousandsFormatter } from "@/utils/table_col_formatter";
export default {
  name: "QueryDetails",
  components: {
    OstInfo,
  },
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      detailsData: {} , // 明细操作传值
      // 是否显示弹出层
      open: false,
      reqConfig: detailTabSearch,
      // 查询参数
      queryParams: {
        reId: "",
      },
      opButtonList: () => {
        return [];
      },
      tableBindColumns: [
        {
          label: `明细流水号`,
          prop: "id",
          width: "150",
          sortable: false,
        },
        {
          label: `贷记清算行行号`,
          prop: "cStBrno",
          width: "150",
          sortable: false,
        },

        {
          label: `借记清算行行号`,
          prop: "dStBrno",
          width: "150",
          sortable: false,
        },
        {
          label: `拆入行剩余可用拆借额度币种`,
          prop: "rmngAmtCurcd",
          dictCode: "CURCD",
          width: "200",
          sortable: false,
        },
        {
          label: `拆入行剩余可用拆借额度`,
          prop: "rmngAmt",
          width: "200",
          sortable: false,
          type: "price",
        },
        {
          label: `交易明细数目`,
          prop: "dtlNum",
          sortable: false,
          width: "120",
        },
      ],
    };
  },
  mounted() {},
  watch: {
    open(d) {
      if (d) {
        this.$nextTick(() => {
          if (this.formData && this.formData.reId) {
            this.$set(this.queryParams, "reId", this.formData.reId);
            this.$refs.flowTable.doQuery();
          }
        });
      }
    },
  },
  methods: {
    // 表单重置
    reset() {
      this.resetForm("detailsForm");
      // this.$set(this, "form", {});
    },
    closeFn() {
      this.open = false;
      this.reset();
    },
    show() {
      this.open = true;
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "detailsInfo":
          // 设置
          this.detailsData = _.clone(row);
          this.$refs.ostInfoDialog.show();
          break;
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
